<!DOCTYPE html>
<html>
	<head>
    	<meta charset="utf-8"/>
		<title>登录页面</title>
		<link rel="stylesheet" href="static/assets/css/normalize.css">
		<link rel="stylesheet" href="static/assets/css/bootstrap.min.css">
		<link rel="stylesheet" href="static/assets/css/font-awesome.min.css">
		<link rel="stylesheet" href="static/assets/css/themify-icons.css">
		<link rel="stylesheet" href="static/assets/css/pe-icon-7-filled.css">
		<link rel="stylesheet" href="static/assets/css/flag-icon.min.css">
		<link rel="stylesheet" href="static/assets/css/cs-skin-elastic.css">
		<link rel="stylesheet" href="static/assets/css/style.css">
		<link rel="shortcut icon" href="static/images/4545-1.ico">
		<style type="text/css">
			.container{height: 100vh;display: flex;}
			.login-content{margin: auto;}
			.verify{display: flex;}
			#v_container{display: block;height: 38px;margin-left: 15px;width: 180px;}
			label.error{color: red;display: block;padding-top: 3px;}
		</style>
	</head>
	<body style="background: #fece25;">
		<div class="sufee-login d-flex align-content-center flex-wrap">
	        <div class="container">
	            <div class="login-content">
	                <div class="login-logo">
	                    <a href="index.html">
	                        <img class="align-content" src="static/images/houtao1.jpg" width="300">
	                    </a>
	                </div>
	                <div class="login-form">
	                    <form name="loginForm">
	                        <div class="form-group">
	                            <label>用户名</label>
	                            <input type="text" name="username" value="" class="form-control"  placeholder="请输入用户名">
	                        </div>
	                        <div class="form-group">
	                            <label>密码</label>
	                            <input class="form-control" placeholder="请输入密码" type="password" name="password" value="" AUTOCOMPLETE="off"/>
	                        </div>
	                        <button type="submit" class="btn btn-success btn-flat m-b-30 m-t-30">登录</button>
	                    </form>
	                </div>
	            </div>
	        </div>
	    </div>
	</body>
	<script src="static/assets/js/vendor/jquery-2.1.4.min.js"></script>
	<script src="static/jquery-validate/jquery.validate.min.js"></script>
	<script src="static/layer/layer.js"></script>
	<script src="static/js/ajax.js"></script>
	<script type="text/javascript">
		$("form").validate({
			"rules":{
				username:{
					required:true
				},
				password:{
					required:true
				}
			},
			messages:{
				username:{
					required:"请输入账户"
				},
				password:{
					required:"请输入密码"
				}
			},
			submitHandler:function(){
				login();
			}
		});
		
		//登录
		function login(){
			loginHttp({
				type:"post",
				data:$("form").serialize(),
				url:"auth/login",
				success:function(msg){
					console.info(msg);
					//token存入本地
					localStorage.setItem('access_token', msg.result);
					ajaxHttp({
						url:"system/admin/getAdminByToken",
						success:function(user){
							console.info(user.data.username);
							//得到用户信息并存入本地
							localStorage.setItem('username', user.data.username);
							location.href="main.html";
						}
					})
					
				},
				error:function(msg){
				    layer.alert(msg.responseJSON.message,{icon:5});
				}
			})
		}
	</script>
</html>
